<?php
/**
 * @purpose: 对“通知”类型中子类型为8(请求加好友成功后，给发出邀请者的一个回馈通知)的编码与解码文件
 * @author: Mandel Woo <wuzhijian@snda.com>

 * @memo: 参阅母板文件
 */
require_once(dirname(__FILE__)."/../../../models/user/UCModUserInfo.php");


function msg_notice_type8_encoder() {
	$fields = array("usr_id");

	foreach($fields as $k => $v) {
		eval("\${$v}=func_get_arg($k);");
	}

	#B接受了你的好友请求+时间
	return serialize(array(
			"usr_id" => $usr_id,
			));
}

function msg_notice_type8_decoder() {
	$fields = array("id","receiverid","content","createTime","changeFlag","fmt");

	foreach($fields as $k => $v) {
		eval("\${$v}=func_get_arg($k);");
	}

	$data     = unserialize($content);
	$o_usr    = UCModUserInfo::getUser($data['usr_id']);
	$nickname = $o_usr->getName();
	$nickname == '' && $nickname = $data['usr_id']; #取不到昵称
	$nickname = htmlspecialchars($nickname);

	$usr = "<a href=\"".get_user_home_url($data['usr_id'])."\" target='_blank'>{$nickname}</a>";

	#!!!输出处将不做html转义，须保证用户输入数据的安全
	if ($fmt == 'line') {
		return sprintf("%s接受了你的好友请求", $usr);

	} else if ($fmt == 'box') {
		$html = sprintf("%s接受了你的好友请求", $usr);
		return '<div class="font14">' . $html . '</div>';

	} else {
		return '';
	}
}


